import http from '@/utils/http'

const BASE_URL = '/asset/consumable/category'


export interface ConsumableCategoryResp {
  id: string
  name: string
  parentId: string
  ancestors: string
  description: string
  sort: string
  status: string
  isSystem: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  createUserString: string
  updateUserString: string
  disabled: boolean
}
export interface ConsumableCategoryDetailResp {
  id: string
  name: string
  parentId: string
  ancestors: string
  description: string
  sort: string
  status: string
  isSystem: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface ConsumableCategoryQuery {
  name: string | undefined
  parentId: string | undefined
  ancestors: string | undefined
  status: string | undefined
  isSystem: string | undefined
  createUser: string | undefined
  createTime: string | undefined
  sort: Array<string>
}
export interface ConsumableCategoryPageQuery extends ConsumableCategoryQuery, PageQuery {}

/** @desc 查询耗材分类列表 */
export function listConsumableCategory(query: ConsumableCategoryPageQuery) {
  return http.get<ConsumableCategoryResp[]>(`${BASE_URL}/tree`, query)
}

/** @desc 查询耗材分类详情 */
export function getConsumableCategory(id: string) {
  return http.get<ConsumableCategoryDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增耗材分类 */
export function addConsumableCategory(data: any) {
  return http.post(BASE_URL, data)
}

/** @desc 修改耗材分类 */
export function updateConsumableCategory(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除耗材分类 */
export function deleteConsumableCategory(id: string) {
  return http.del(BASE_URL, { ids: [id] })
}

/** @desc 导出耗材分类 */
export function exportConsumableCategory(query: ConsumableCategoryQuery) {
  return http.download(`${BASE_URL}/export`, query)
}
